﻿using System;
using System.Collections.Generic;
using System.Text;

using E.Model;
using E.DAL;

namespace E.BLL
{
    public class TeacherBLL
    {
        private TeacherDAL dal;

        public TeacherBLL()
        {
            dal = new TeacherDAL();
        }
        
        /// <summary>
        /// 添加教师
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddTeacher(TeacherModel model)
        {
            return dal.AddTeacher(model);
        }

        /// <summary>
        /// 更新教师
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateTeacherWithArea(TeacherModel model)
        {
            return dal.UpdateTeacherWithArea(model);
        }
        
        /// <summary>
        /// 检查登录ID
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public bool CheckExistLoginID(string loginid)
        {
            return dal.CheckExistLoginID(loginid);
        }

        /// <summary>
        /// 老师登录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public TeacherModel Login(TeacherModel model)
        {
            return dal.Login(model);
        }

        /// <summary>
        /// 获取老师所在地区列表
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public IList<DictAreaModel> GetTeacherAreaList(int teacherid)
        {
            return dal.GetTeacherAreaList(teacherid);
        }

        /// <summary>
        /// 根据地区获取老师列表
        /// </summary>
        /// <param name="areaid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetTeacherByArea(int areaid)
        {
            return dal.GetTeacherByArea(areaid);
        }

        /// <summary>
        /// 获取内训老师列表
        /// </summary>
        /// <param name="projectid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetTeacherByProjectID(int projectid)
        {
            return dal.GetTeacherByProjectID(projectid);
        }

        /// <summary>
        /// 搜索教师
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public TeacherListModel GetTeacherListByCondition(SearchTeacherModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetTeacherListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="teacherid"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public int UpdatePassword(int teacherid, string pwd)
        {
            return dal.UpdatePassword(teacherid, pwd);
        }

        /// <summary>
        /// 修改密码（需要原密码）
        /// </summary>
        /// <param name="teacherid"></param>
        /// <param name="originalpwd"></param>
        /// <param name="newpwd"></param>
        /// <returns></returns>
        public int UpdatePasswordWithOriginalPwd(int teacherid, string originalpwd, string newpwd)
        {
            return dal.UpdatePasswordWithOriginalPwd(teacherid, originalpwd, newpwd);
        }

        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateTeacherInfo(TeacherModel model)
        {
            return dal.UpdateTeacherInfo(model);
        }

        /// <summary>
        /// 获取老师信息
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public TeacherModel GetTeacherInfo(int teacherid)
        {
            return dal.GetTeacherInfo(teacherid);
        }
        /// <summary>
        /// 获取老师邮件提醒配置时间
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public int GetTeacherMailDay(int teacherid)
        {
            return dal.GetTeacherMailDay(teacherid);
        }
        /// <summary>
        /// 获取用户地区ID列表
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public IList<int> GetTeacherAreaIDList(int teacherid)
        {
            return dal.GetTeacherAreaIDList(teacherid);
        }

        /// <summary>
        /// 获取教师所教班级课程列表
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public IDictionary<int, string> GetTeacher2ClassCourseList(int teacherid)
        {
            return dal.GetTeacher2ClassCourseList(teacherid);
        }

        /// <summary>
        /// 激活教师账号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int ActiveTeacher(int id)
        {
            return dal.ActiveTeacher(id);
        }

        /// <summary>
        /// 冻结教师账号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int FreezeTeacher(int id)
        {
            return dal.FreezeTeacher(id);
        }


        #region q and a

        /// <summary>
        /// 添加问题
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddQuestion(QandAModel model)
        {
            return dal.AddQuestion(model);
        }

        /// <summary>
        /// 回复答疑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int ReplyQnA(QandAModel model)
        {
            return dal.ReplyQnA(model);
        }

        /// <summary>
        /// 获取QnA信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public QandAModel GetQnAInfo(int id)
        {
            return dal.GetQnAInfo(id);
        }
        
        /// <summary>
        /// 获取新回复QnA总数
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int GetNewReplyQnACount(int userid)
        {
            return dal.GetNewReplyQnACount(userid);
        }

        /// <summary>
        /// 获取未回复QnA总数
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public int GetUnreplyQnACount(int teacherid)
        {
            return dal.GetUnreplyQnACount(teacherid);
        }

        /// <summary>
        /// 更新未查看回复QnA标识
        /// </summary>
        /// <param name="qandaid"></param>
        /// <returns></returns>
        public int UpdateNewReplyQnAFlag(int qandaid)
        {
            return dal.UpdateNewReplyQnAFlag(qandaid);
        }

        /// <summary>
        /// 获取Q&A列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public QandAListModel GetQandAListByCondition(SearchQandAListModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetQandAListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 获取Q&A列表（admin）
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public QandAListModel GetQandAListByCondition2(SearchQandAListModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetQandAListByCondition2(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 删除答疑
        /// </summary>
        /// <param name="qnaid"></param>
        /// <returns></returns>
        public int DelQnA(string[] qnaid)
        {
            return dal.DelQnA(qnaid);
        }

        #endregion

        #region 忘记密码

        /// <summary>
        /// 获取用户忘记密码信息
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public IDictionary<int, string> GetForgetPwdInfoByLoginID(string loginid)
        {
            return dal.GetForgetPwdInfoByLoginID(loginid);
        }

        /// <summary>
        /// 获取用户提示问题
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public PwdQuestionModel GetForgetPwdQuestionID(int teacherid)
        {
            return dal.GetForgetPwdQuestionID(teacherid);
        }

        /// <summary>
        /// 检查用户忘记密码提示问题答案是否正确
        /// </summary>
        /// <param name="teacherid"></param>
        /// <param name="answer"></param>
        /// <returns></returns>
        public int CheckForgetPwdAnswer(int teacherid, string answer)
        {
            return dal.CheckForgetPwdAnswer(teacherid, answer);
        }

        /// <summary>
        /// 获取忘记密码提示问题列表
        /// </summary>
        /// <returns></returns>
        public IDictionary<int, string> GetForgetPwdQuestionList()
        {
            return dal.GetForgetPwdQuestionList();
        }

        /// <summary>
        /// 更新安全信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateFortgetPwdInfo(PwdQuestionModel model)
        {
            return dal.UpdateFortgetPwdInfo(model);
        }

        #endregion

        #region 内训

        /// <summary>
        /// 获取老师项目组信息
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetTeacherProjectInfo(int teacherid)
        {
            return dal.GetTeacherProjectInfo(teacherid);
        }

        /// <summary>
        /// 获取教师项目ID
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public int GetTeacherProjectID(int teacherid)
        {
            return dal.GetTeacherProjectID(teacherid);
        }


        #endregion
    }
}
